package com.seewo.dubbo.debugger.admin.common;

import org.springframework.util.Assert;

/**
 * @author chenliangliang
 * @date 2018/8/3
 */
public abstract class AbstractServiceDiscovery<T> implements ServiceDiscovery {

    protected String address;
    int connectionTimeout;


    AbstractServiceDiscovery(String address, int connectionTimeout) {
        Assert.hasText(address, "address can not be empty");
        this.address = address;
        this.connectionTimeout = connectionTimeout;
    }

    /**
     * 获取注册中心的连接客户端
     *
     * @return
     */
    protected abstract T getClient();

    AbstractServiceDiscovery(String address) {
        this(address, 5000);
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public int getConnectionTimeout() {
        return connectionTimeout;
    }

    public void setConnectionTimeout(int connectionTimeout) {
        this.connectionTimeout = connectionTimeout;
    }
}
